package com.xying.common;

import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 *
 * @author Hisen
 * @date 2017/11/5
 */
public class Const {
  public static String NO_DATA = "--";
  public static String DEFAULT_CONFIG_FILE = "zq.properties";
  public static String KEYWORD_MANAGE = "manage";
  public static String DEFAULT_REPORT_INTERVAL = "3600.0";
  public static String USR_DOMAIN = "domain";

  public static Map<Integer, List<Integer>> sensorTypeMap;
  public static Map<Integer, String> sensorTypeNameMap = Maps.newHashMap();

  public interface RedisCache {
    int REDIS_SESSION_EXTIME = 60 * 30;
  }

  public interface CookieName {
    String ADMIN_COOKIE_NAME = "mpf_admin_cookies_token";
  }

  /**
   * 用户的权限枚举
   */
  public enum ROLE{
    NORMAL_USR(0, "NORMAL_USR"),
    ADMIN_USR(10, "ADMIN_USR"),
    SUPER_USR(20, "SUPER_USR");

    private int code;
    private String desc;

    ROLE(int code, String desc){
      this.code = code;
      this.desc = desc;
    }

    public int getCode() {
      return code;
    }

    public String getDesc() {
      return desc;
    }
  }

  /**
   * 状态的权限枚举
   */
  public enum STATUS{
    PROJECT_EDIT(0, "PROJECT_EDIT"),
    PROJECT_OVER(1, "PROJECT_OVER"),
    PROJECT_FINAL(2, "PROJECT_FINAL"),
    MARK_DETAIL_COUNT(5, "PROJECT_FINAL"),
    BOUNDARY_COUNT(4, "BOUNDARY_COUNT");

    private int code;
    private String desc;

    STATUS(int code, String desc){
      this.code = code;
      this.desc = desc;
    }

    public int getCode() {
      return code;
    }

    public String getDesc() {
      return desc;
    }
  }

  /**
   * 表的名称枚举
   */
  public enum Table{
    SQL_DESC("DESC"),
    SQL_ASC("ASC"),
    ZQ_ADMIN_DEVICE("ZQ_ADMIN_DEVICE"),
    ZQ_ADMIN_SENSOR("ZQ_ADMIN_SENSOR"),
    ZQ_DEVICE("ZQ_DEVICE"),
    ZQ_LAND("ZQ_LAND"),
    ZQ_SENSOR("ZQ_SENSOR");

    private String name;

    Table(String name){
      this.name = name;
    }

    public String getName() {
      return name;
    }
  }

  /**
   * 字段的名称枚举
   */
  public enum Column{
    ZQ_SENSOR_UP("UP"),
    ZQ_SENSOR_LOWER("LOWER");

    private String name;

    Column(String name){
      this.name = name;
    }

    public String getName() {
      return name;
    }
  }


  /**
   * 表的名称枚举
   */
  public enum Error_MSG{
    /**
     * 用户名或密码错误
     */
    ERROR_USER_USERNAME_PASSWORD(100),
    /**
     * 用户不存在
     */
    ERROR_USER_USERNAME_NOT_EXIST(101),
    /**
     * 旧密码错误
     */
    ERROR_USER_OLD_PASSWORD(102),
    /**
     * 修改信息失败
     */
    ERROR_USER_UPDATE_USER_INFO(103),
    /**
     * 不是管理员用户
     */
    ERROR_USER_NOT_ADMIN_USER(104),
    /**
     * 查询用户失败
     */
    ERROR_USER_LIST_USER(105),
    /**
     * 获取到的信息为空
     */
    ERROR_USER_SECURE_MSG_EMPTY(106),
    /**
     * 用户名已存在
     */
    ERROR_USER_USERNAME_ALREADY_EXIST(107),
    /**
     * 删除指定用户失败
     */
    ERROR_USER_DELETE_USER(108),
    /**
     * 查询用户信息失败
     */
    ERROR_USER_SEARCH_USER_INFO(109),


    /**
     * 获取传感器信息失败
     */
    ERROR_SENSOR_GET_INFO(200),
    /**
     * 暂无传感器或类型错误
     */
    ERROR_SENSOR_TYPE_AND_SENSOR(201),
    /**
     * 修改传感器域值失败
     */
    ERROR_SENSOR_SET_SENSOR_TOP(202),
    /**
     * 删除传感器失败
     */
    ERROR_SENSOR_DELETE(203),
    /**
     * 导出传感器数据失败
     */
    ERROR_SENSOR_DATA_EXPORT(204),


    /**
     * 添加地块信息失败
     */
    ERROR_LAND_ADD(300),
    /**
     * 修改地块信息失败
     */
    ERROR_LAND_UPDATE(301),
    /**
     * 删除指定地块失败
     */
    ERROR_LAND_DELETE(302),
    /**
     * 设备异常:已删除异常设备
     */
    ERROR_DEVICE_ALREADY_DELETE(400),
    /**
     * 删除指定设备失败
     */
    ERROR_DEVICE_DELETE(401),
    /**
     * 校验地块失败
     */
    ERROR_DEVICE_CHECK_LAND(402),
    /**
     * 获取未注册设备信息失败
     */
    ERROR_DEVICE_GET_UNREGISTER_DEVICE(403),
    /**
     * 获取未注册传感器信息失败
     */
    ERROR_DEVICE_GET_UNREGISTER_SENSOR(404),
    /**
     * 含有重复设备ID
     */
    ERROR_DEVICE_HAVE_REPEAT_ID(405),


    /**
     * 添加相机失败
     */
    ERROR_CAMERA_ADD(500),
    /**
     * 修改相机信息失败
     */
    ERROR_CAMERA_UPDATE(501),
    /**
     * 删除相机失败
     */
    ERROR_CAMERA_DELETE(502);

    private int code;

    Error_MSG(int code){
      this.code = code;
    }

    public int getCode() {
      return code;
    }
  }

  public static String getUUID(){
    return UUID.randomUUID().toString().replace("-", "");
  }
}
